using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The SchoolAddressTableManager class is responsible for managing BO.SchoolAddressTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class SchoolAddressTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all SchoolAddressTable objects in the database.
/// </summary>
/// <returns>A list with all SchoolAddressTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static SchoolAddressTableList GetList(){
return SchoolAddressTableDB.GetList();
}

/// <summary>
/// Gets a single SchoolAddressTable from the database without its data.
/// </summary>
/// <param name="schoolAddressKey">The SchoolAddressKey of the SchoolAddressTable in the database.</param>
/// <returns>A SchoolAddressTable object when the SchoolAddressKey exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static SchoolAddressTable GetItem(int schoolAddressKey){
return GetItem(schoolAddressKey, false);
}

/// <summary>
/// Gets a single SchoolAddressTable from the database.
/// </summary>
/// <param name="schoolAddressKey">The SchoolAddressKey of the SchoolAddressTable in the database.</param>
/// <param name="getSchoolAddressTableRecords">Determines whether to load all associated SchoolAddressTable records as well.</param>
/// <returns>
/// A SchoolAddressTable object when the SchoolAddressKey exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static SchoolAddressTable GetItem(int schoolAddressKey, bool getSchoolAddressTableRecords){
SchoolAddressTable mySchoolAddressTable = SchoolAddressTableDB.GetItem(schoolAddressKey);
return mySchoolAddressTable;
}

/// <summary>
/// Saves a SchoolAddressTable in the database.
/// </summary>
/// <param name="mySchoolAddressTable">The SchoolAddressTable instance to save.</param>
/// <returns>The new SchoolAddressKey if the SchoolAddressTable is new in the database or the existing SchoolAddressKey when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static int Save(SchoolAddressTable mySchoolAddressTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
int schoolAddressTableSchoolAddressKey = SchoolAddressTableDB.Save(mySchoolAddressTable);

//  Assign the SchoolAddressTable its new (or existing SchoolAddressKey).
mySchoolAddressTable.SchoolAddressKey = schoolAddressTableSchoolAddressKey;

myTransactionScope.Complete();

return schoolAddressTableSchoolAddressKey;
}
}

/// <summary>
/// Deletes a SchoolAddressTable from the database.
/// </summary>
/// <param name="mySchoolAddressTable">The SchoolAddressTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(SchoolAddressTable mySchoolAddressTable){
return SchoolAddressTableDB.Delete(mySchoolAddressTable.SchoolAddressKey);
}

#endregion

}

}
